import { createRouter, createWebHashHistory } from "vue-router";
import layout from "@/layout/index.vue";
import Home from "../views/Home.vue";
import Form from "@/views/Form.vue";
import onFound from "@/views/404.vue";
import BaseForm from "@/views/BaseForm.vue";
import tree_base from "@/views/tree/base.vue";
import tree_index from "@/views/tree/index.vue";
import tree_table from "@/views/tree/table.vue";
import update_index from "@/views/update/index.vue";
import entry_index from "@/views/entry/index.vue";
import login from "@/views/login.vue";
import test_index from "@/views/test/index.vue";
import test_one_index from "@/views/test/one/index.vue";
import test_two_index from "@/views/test/two/index.vue";
import test_entry_index from "@/views/test/entry/index.vue";
import parent from "@/layout/parent.vue";
// import store from "../store/index";
export const routes = [
  {
    path: "/home",
    pid: 0,
    id: 1,
    name: "Home",
    component: layout,
    redirect: "/home/index",
    meta: {
      icon: "UserOutlined",
      title: "表单管理",
      cache: true,
      hidden: false,
    },
    children: [
      {
        path: "/home/index",
        component: Home,
        pid: 1,
        id: 2,
        name: "home_index",
        meta: {
          title: "表格",
          cache: true,
          hidden: false,
        },
      },
      {
        path: "/home/home_form",
        component: Form,
        name: "home_form",
        pid: 1,
        id: 3,
        meta: {
          title: "表单模型",
          cache: true,
          icon: "user",
          hidden: false,
        },
      },
      {
        path: "/home/home_base",
        component: BaseForm,
        name: "home_base",
        pid: 1,
        id: 4,
        meta: {
          title: "基础表单",
          cache: true,
          hidden: false,
        },
        children: [
          {
            path: "/entry/index1",
            component: entry_index,
            name: "entry_index1",
            pid: 4,
            id: 5,
            meta: {
              icon: "user",
              title: "工作台1",
              cache: false,
              hidden: false,
            },
          },
        ],
      },
    ],
  },

  {
    path: "/tree",
    name: "tree",
    pid: 0,
    id: 6,
    component: layout,
    redirect: "/tree/tree_index",
    meta: {
      icon: "TeamOutlined",
      title: "权限管理",
      cache: false,
      hidden: false,
    },
    children: [
      {
        pid: 6,
        id: 7,
        path: "/tree/tree_index",
        component: tree_table,
        name: "tree_index",
        meta: {
          title: "权限树",
          cache: false,
          hidden: false,
        },
      },
      // {
      //   pid: 6,
      //   id: 8,
      //   path: "/tree/table",
      //   component: tree_index,
      //   name: "tree_table",
      //   meta: {
      //     title: "表单模型",
      //     cache: false,
      //     hidden: false,
      //   },
      // },
      {
        pid: 6,
        id: 9,
        path: "/tree/BaseForm",
        component: tree_base,
        name: "tree_base",
        meta: {
          title: "基础表单",
          cache: false,
          hidden: false,
        },
      },
    ],
  },
  {
    path: "/update",
    name: "update",
    pid: 0,
    id: 10,
    component: layout,
    meta: {
      icon: "DesktopOutlined",
      title: "更新实例",
      cache: false,
      hidden: false,
    },
    redirect: "/update1",
    children: [
      {
        path: "/update1",
        component: update_index,
        pid: 10,
        id: 11,
        name: "update_index1",
        meta: {
          title: "修改表格",
          cache: false,
          hidden: false,
        },
      },
      {
        path: "/tree/table1",
        pid: 10,
        id: 12,
        component: tree_index,
        name: "tree_table",
        meta: {
          title: "表单模型",
          cache: false,
          hidden: false,
        },
      },
      {
        path: "/tree/test",
        component: parent, // parent test_index
        name: "test_index",
        pid: 10,
        id: 13,
        redirect: "/test/entry/index",
        meta: {
          title: "测试",
          cache: false,
          hidden: false,
        },
        children: [
          {
            path: "/test/index/one",
            component: test_one_index,
            pid: 13,
            id: 14,
            name: "test_one_index",
            meta: {
              title: "测试1",
              cache: false,
              hidden: false,
            },
          },
          {
            pid: 13,
            id: 14,
            path: "/test/index/two",
            component: test_two_index,
            name: "test_two_index",
            meta: {
              title: "测试2",
              cache: false,
              hidden: false,
            },
          },
          {
            pid: 13,
            id: 15,
            path: "/test/entry/index",
            component: test_entry_index,
            name: "test_entry_index",
            meta: {
              title: "测试首页",
              cache: false,
              hidden: true,
            },
          },
        ],
      },
    ],
  },
];
export const router_list = [
  {
    path: "/login",
    component: login,
    meta: {
      icon: "user",
      title: "入口",
      cache: false,
      hidden: false,
    },
  },
  {
    path: "/404",
    component: onFound,
  },
  {
    path: "/",
    name: "entry",
    component: layout,
    redirect: "/entry/index",
    meta: {
      icon: "user",
      title: "工作台",
      cache: false,
      hidden: false,
    },
    children: [
      {
        path: "/entry/index",
        component: entry_index,
        name: "entry_index",
        meta: {
          icon: "user",
          cache: false,
          hidden: false,
        },
      },
    ],
  },
];

export default createRouter({
  history: createWebHashHistory(),
  routes: [...router_list, ...routes],
});
